package com.boot.demo.advice;

import com.boot.demo.util.HttpStatus;
import com.boot.demo.util.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with LXD
 *
 * @author:Luhui
 * @qq:729913162
 * @Date:2018-08-11
 * @Time:11:34
 */
@org.springframework.web.bind.annotation.ControllerAdvice
public class ControllerAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    JsonResult handleException(Exception e){
        return new JsonResult(null,HttpStatus.INTERNAL_SERVER_ERROR.getStatus(),e.getMessage());
    }
}
